from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re

class Mobiletwitter(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.implicitly_wait(30)
        self.base_url = "https://mobile.twitter.com/"
        self.verificationErrors = []
    
    def test_mobiletwitter(self):
        driver = self.driver
        driver.get("https://mobile.twitter.com/session/new")
        driver.find_element_by_id("username").clear()
        driver.find_element_by_id("username").send_keys("serinskiivan")
        driver.find_element_by_id("password").clear()
        driver.find_element_by_id("password").send_keys("1q2w3e4r")
        driver.find_element_by_id("signupbutton").click()
        driver.find_element_by_id("tweet_text").clear()
        driver.find_element_by_id("tweet_text").send_keys("Ку")
        driver.find_element_by_id("tweet_submit").click()
        driver.find_element_by_id("tweet_submit").click()
    
    def is_element_present(self, how, what):
        try: self.driver.find_element(by=how, value=what)
        except NoSuchElementException, e: return False
        return True
    
    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
    unittest.main()
